package com.easyj.admin.activiti.config;

import org.activiti.api.task.runtime.events.TaskAssignedEvent;
import org.activiti.api.task.runtime.events.TaskCreatedEvent;
import org.activiti.api.task.runtime.events.listener.TaskRuntimeEventListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * 
 * @author hjf
    *   全局task事件监听，可据需要监听task的创建、拾取、完成、更新、删除、挂起、激活各类状态
 */
@Configuration
public class TaskRuntimeEventListenerConfig {
	
	//private RuntimeService runtimeService;
	
	//public TaskRuntimeEventListenerConfig(RuntimeService runtimeService) {
	//	this.runtimeService=runtimeService;
	//}
	  /**
                       * 监听task的创建
     *
     * @return taskCreated
     */
    @Bean
    public TaskRuntimeEventListener<TaskCreatedEvent> taskCreatedListener() {
        return taskCreated -> {
        	//taskCreated.getEntity().getProcessInstanceId();
        	//taskCreated.getEntity().getAssignee();
        	//ExecutionEntity execution = (ExecutionEntity) runtimeService.createProcessInstanceQuery()
            //        .processInstanceId(taskCreated.getProcessInstanceId()).singleResult();
        	
        	
           
        	  
        };
    }
    
    /**
     * 监听taskAssigned
     *
     * @return taskAssigned
     */
    @Bean
    public TaskRuntimeEventListener<TaskAssignedEvent> taskAssignedListener() {
        return taskAssigned ->{ 
        	//taskAssigned.getEntity().getName();
            //taskAssigned.getEntity().getAssignee();
        	
        };
    }


}
